/*
* pps_bom
*/
package com.pitop.bom.service;

import com.pitop.bom.api.BomDetailLogFeignApi;
import com.pitop.bom.entity.BomDetailLog;
import com.pitop.core.entity.Page;
import com.pitop.core.exceptions.BaseException;
import com.pitop.core.exceptions.BomDetailLogException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * bom明细日志
 *
 * @author berton
 */
@Service("bomDetailLogSVImpl")
@Slf4j
public class BomDetailLogSVImpl {

    @Autowired
    private BomDetailLogFeignApi bomDetailLogFeignApi;

    /**
     * 加载一个对象BomDetailLog
     *
     * @param id
     * @return BomDetailLog
     */
    public BomDetailLog load(Long id) {
        if (id == null) {
            throw new BomDetailLogException(BaseException.BaseExceptionEnum.Illegal_Param);
        }
        return bomDetailLogFeignApi.load(id);
    }

    /**
     * 加载一个对象BomDetailLog 通过id,(将查询关联数据)
     *
     * @param id
     * @return BomDetailLog
     */
    public BomDetailLog loadById(Long id) {
        if (id == null) {
            throw new BomDetailLogException(BaseException.BaseExceptionEnum.Illegal_Param);
        }
        return bomDetailLogFeignApi.loadById(id);
    }

    /**
     * 加载一个对象BomDetailLog,(将查询关联数据)
     *
     * @param id
     * @return BomDetailLog
     */
    public BomDetailLog get(Long id) {
        if (id == null) {
            throw new BomDetailLogException(BaseException.BaseExceptionEnum.Illegal_Param);
        }
        return bomDetailLogFeignApi.get(id);
    }

    /**
     * 加载一个对象BomDetailLog 通过id,(将查询关联数据)
     *
     * @param id
     * @return BomDetailLog
     */
    public BomDetailLog getById(Long id) {
        if (id == null) {
            throw new BomDetailLogException(BaseException.BaseExceptionEnum.Illegal_Param);
        }
        return bomDetailLogFeignApi.getById(id);
    }

    /**
     * 删除对象BomDetailLog
     *
     * @param id
     */

    public void delete(Long id) {
        if (id == null) {
            throw new BomDetailLogException(BaseException.BaseExceptionEnum.Illegal_Param);
        }
        bomDetailLogFeignApi.delete(id);
    }

    /**
     * 查询BomDetailLog分页
     *
     * @param bomDetailLog 对象
     * @param curPage      当前页
     * @param pageSize     分页条数
     * @return List<BomDetailLog>
     */
    public List<BomDetailLog> list(BomDetailLog bomDetailLog, int curPage, int pageSize) {
        return bomDetailLogFeignApi.list(bomDetailLog, curPage, pageSize);
    }

    /**
     * 查询BomDetailLog分页
     *
     * @param id
     * @param curPage  当前页
     * @param pageSize 分页条数
     * @return List<BomDetailLog>
     */
    public List<BomDetailLog> list(Long id, int curPage, int pageSize) {
        if (curPage < 0) {
            curPage = 1;
        }

        if (pageSize < 0) {
            pageSize = Page.limit;
        }

        BomDetailLog bomDetailLog = new BomDetailLog();
        bomDetailLog.setId(id);

        return bomDetailLogFeignApi.list(bomDetailLog, curPage, pageSize);
    }

    public int count(Long id) {
        return bomDetailLogFeignApi.count(id);
    }

    public int count(BomDetailLog bomDetailLog) {
        return bomDetailLogFeignApi.count(bomDetailLog);
    }

    /**
     * 保存
     *
     * @param bomDetailLog 实体
     * @throws BaseException
     */
    public void save(BomDetailLog bomDetailLog) {
        if (bomDetailLog == null) {
            throw new BomDetailLogException(BaseException.BaseExceptionEnum.Illegal_Param);
        }
        bomDetailLogFeignApi.build(bomDetailLog);
    }

    /**
     * 更新
     *
     * @param bomDetailLog 实体
     * @throws BaseException
     */
    public void modify(BomDetailLog bomDetailLog) {
        if (bomDetailLog == null) {
            throw new BomDetailLogException(BaseException.BaseExceptionEnum.Illegal_Param);
        }
        bomDetailLogFeignApi.modify(bomDetailLog);
    }
}
